{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.17 Sizing of Pump for Oil Pipelines"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Crude oil (30 degree API) at 15.6 C with a viscosity of 75 Universal Saybolt seconds flows down a 12\" Schedule 30 steel pipe with a flow rate of 1900 barrels/hour.\n",
    "\n",
    "The pipeline is 50 miles long, and the net elevation change is an increase of 2000 feet above the initial pump. The pump has an efficiency of 67%.\n",
    "\n",
    "Calculate the brake horsepower of the pump."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24364.090937022276 dimensionless\n",
      "0.02511025708497868 dimensionless\n",
      "head = 3413.763958141052 foot\n",
      "power = 1499.9449484211073 horsepower\n"
     ]
    }
   ],
   "source": [
    "from fluids.units import *\n",
    "from math import pi\n",
    "L = 50*u.miles\n",
    "dH = 2000*u.foot\n",
    "efficiency = 0.67\n",
    "\n",
    "# Note in pint the default barrel is for US dry barrel\n",
    "Q = 1900*u.oil_barrel/u.hour\n",
    "mu = 12.5*u.cP\n",
    "rho = 54.64*u.lb/u.ft**3\n",
    "\n",
    "NPS, Di, Do, t = nearest_pipe(NPS=12, schedule='30')\n",
    "\n",
    "A = 0.25*pi*Di**2\n",
    "v = Q/A\n",
    "Re = rho*v*Di/mu\n",
    "print(Re.to_base_units())\n",
    "fd = friction_factor(Re=Re, eD=0.0022*u.inch/Di)\n",
    "print(fd)\n",
    "\n",
    "K_tot = K_from_f(fd=fd, L=L, D=Di)\n",
    "dP = dP_from_K(K=K_tot, rho=rho, V=v) + rho*dH*1*u.gravity\n",
    "dP.to(u.psi), v.to(u.foot/u.s)\n",
    "\n",
    "head = head_from_P(dP, rho).to(u.foot)\n",
    "print('head = %s' %head)\n",
    "power = Q*dP/efficiency\n",
    "print('power = %s' %(power.to(u.hp)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The listed values are 3406.5 feet and 1496 hp, however a shortcut formula is used there."
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
